
const util = require('../../utils/timeTool.js');
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    time:'',
    id:'',
    birthdayPerson:'',
    orUrl:'',
    birthday:'',
    birthdayLunarStr:'',
    birthdayDefault:'',
    relationUrl:'',
    isOpen:false,
    isShare:0
  },
  /**
   * 生命周期函数--监听页面加载
   */
  //详情
  getDetails(){
    var that = this
    app.req({
      url: "wechat/birthManage/blessingDetail",
      method: "post",
      data: {
        id: that.data.id
      },
      success: function (res) {
        if (200 == res.code) {
          console.log("生日", res)
          that.setData({
            birthday: util.itemDateToShow(res.data.birthday, 1, false, false).substring(5, 11),
            birthdayLunarStr: res.data.birthdayLunarStr.substring(9, 13),
            birthdayDefault: res.data.birthdayDefault,
            orUrl: res.data.orUrl,
            birthdayPerson: res.data.birthdayPerson,
            relationUrl: res.data.relationUrl
          })
        }
      }
    })
  },
  //详情跳转
  tapSaveImg(){
    var that=this
    wx.navigateTo({
      url: '/pages/partySettingMemo/partySettingMemo?id='+that.data.id,
    })
  },
  onLoad: function(options) {
    var that = this
    console.log('活动id0000', options)
    that.setData({
      id: options.id || options.scene,
      // time:options.time
    })
    console.log('活动id0000')
    console.log('活动id', that.data.id)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },
  onUnload: function () {
    console.log("走了onUnload--", this.data.isBack)
    var pages = getCurrentPages();
    if (pages.length >= 2) {
      var currPage = pages[pages.length - 1];  //当前页面
      var prevPage = pages[pages.length - 2];
      console.log("prevPage返回执行")
      console.log("partyInvitation-pages长度", pages)
      console.log("partyInvitation-prevPage页面", prevPage.route)
      prevPage.setData({
        partyBack: true
      })
    }
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    var that = this
    that.getDetails()
  },
  //分享
  onShareAppMessage: function () {
    var that = this
    app.req({
      url: 'wechat/activity/share',
      data: {
        id: that.data.id,
        type: 2,
      },
      method: 'POST',
      success: function (res) {
        console.log('分享数量', res);
      }
    })
    that.setData({
      isOpen: true,
    })
    return {
      title: '祝' + that.data.birthdayPerson +'生日快乐！',
      path: '/pages/partySettingMemo/partySettingMemo?id=' + that.data.id + '&isShare=1',
      success(e) {
        console.log("分享成功了")
      },
      fail(e) {
        console.log("分享失败")
      }
    }
  }
})
